/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package client.views;

import client.beans.AuthBean;
import client.beans.ServerBean;
import client.types.User;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import server.tools.XMLRequester;
import server.tools.XmlHelper;
import types.RequestXML;
import types.ResponseXML;

/**
 *
 * @author efim
 */
@ManagedBean
@ViewScoped
public class RegistrationView 
{
    
    @EJB
    private ServerBean serverBean;
    
    

    /**
     * Creates a new instance of RegistrationView
     */
    public RegistrationView() 
    {
        
    }
    
    private String fname;

    /**
     * Get the value of fname
     *
     * @return the value of fname
     */
    public String getFname() {
        return fname;
    }

    /**
     * Set the value of fname
     *
     * @param fname new value of fname
     */
    public void setFname(String fname) {
        this.fname = fname;
    }

    private String lname;

    /**
     * Get the value of lname
     *
     * @return the value of lname
     */
    public String getLname() {
        return lname;
    }

    /**
     * Set the value of lname
     *
     * @param lname new value of lname
     */
    public void setLname(String lname) {
        this.lname = lname;
    }

    private String password;

    /**
     * Get the value of password
     *
     * @return the value of password
     */
    public String getPassword() {
        return password;
    }

    /**
     * Set the value of password
     *
     * @param password new value of password
     */
    public void setPassword(String password) {
        this.password = password;
    }
    
    private String email;

    /**
     * Get the value of email
     *
     * @return the value of email
     */
    public String getEmail() {
        return email;
    }

    /**
     * Set the value of email
     *
     * @param email new value of email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    private LinkedList<String> errors;

    /**
     * Get the value of errors
     *
     * @return the value of errors
     */
    public LinkedList<String> getErrors() {
        return errors;
    }

    /**
     * Set the value of errors
     *
     * @param errors new value of errors
     */
    public void setErrors(LinkedList<String> errors) {
        this.errors = errors;
    }

    
    
    
    public void postUser() 
    {
        
            try {                
                Map<String,String> params = new HashMap<>();
                params.put("fname", fname);
                params.put("lname", lname);
                params.put("email", email);
                params.put("password", password);
                serverBean.registrationUser(params);
            } catch (JAXBException ex) {
                Logger.getLogger(RegistrationView.class.getName()).log(Level.SEVERE, null, ex);
            }
             
        
    }
    
}
